package com.xuelang.pipeline.artifact.entry.resource;

import com.xuelang.pipeline.artifact.app.resource.RepositoryComponentService;
import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.IRepositoryComponentService;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryAssetBuildHistoryDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryAssetDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryComponentDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryComponentQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 制品组件 web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/repository-component")
public class RepositoryComponentController implements IRepositoryComponentService {

    @Autowired
    private RepositoryComponentService repositoryComponentService;

    @Override
    public ApiResult<PageRecord<RepositoryComponentDTO>> pageRepositoryComponentList(PageParam<RepositoryComponentQuery> dtoPageParam) {
        return ApiResult.success(repositoryComponentService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<RepositoryComponentDTO>> conditionalRepositoryComponentList(RepositoryComponentQuery repositoryComponentQuery) {
        return ApiResult.success(repositoryComponentService.list(repositoryComponentQuery));
    }

    @Override
    public ApiResult<Boolean> deleteRepositoryComponent(String restId) {
        return ApiResult.success(repositoryComponentService.delete(restId));
    }

    @Override
    public ApiResult<RepositoryComponentDTO> queryRepositoryComponent(String id) {
        return ApiResult.success(repositoryComponentService.query(id));
    }

    @Override
    public ApiResult<List<RepositoryAssetDTO>> listAssetsBytRestId(String restId) {
        return ApiResult.success(repositoryComponentService.listAssetsBytRestId(restId));
    }

    @Override
    public ApiResult<List<RepositoryAssetBuildHistoryDTO>> dockerArtifactBuildHistory(String restId) {
        return ApiResult.success(repositoryComponentService.dockerArtifactBuildHistory(restId));
    }


}